package com.hncc.kumao.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Properties;

import org.springframework.core.io.ClassPathResource;

public class PropertiesUtils {

    private Properties prop = new Properties();
    
    public PropertiesUtils() {
    }
    public PropertiesUtils(String filePath) throws Exception {
        InputStream is = ClassPathResource.class.getClassLoader().getResourceAsStream(filePath);
        //FileInputStream fis = new FileInputStream(filePath);
        prop.load(is);
        is.close();
    }
    
    public String get(String filePath, String key) throws Exception {
        FileInputStream fis = new FileInputStream(filePath);
        prop.load(fis);
        fis.close();
        return prop.getProperty(key);
    }
    
    public String get(String key) {
        return prop.getProperty(key);
    }
}
